package com.lineage.server.serverpackets;

import java.util.ArrayList;
import java.util.Iterator;

public class S_PacketBoxGame extends ServerBasePacket {
  private byte[] _byte;
  
  public static final int GAMESTART = 64;
  
  public static final int TIMESTART = 65;
  
  public static final int GAMEINFO = 66;
  
  public static final int GAMEOVER = 69;
  
  public static final int GAMECLEAR = 70;
  
  public static final int STARTTIME = 71;
  
  public static final int STARTTIMECLEAR = 72;
  
  public S_PacketBoxGame(int subCode) {
    this._byte = null;
    writeC(250);
    writeC(subCode);
  }
  
  public S_PacketBoxGame(int subCode, int value) {
    this._byte = null;
    writeC(250);
    writeC(subCode);
    switch (subCode) {
      case 64:
      case 69:
        writeC(value);
        break;
      case 71:
        writeH(value);
        break;
    } 
  }
  
  public S_PacketBoxGame(ArrayList<StringBuilder> list) {
    this._byte = null;
    writeC(250);
    writeC(66);
    writeC(list.size());
    writeC(0);
    writeC(0);
    writeC(0);
    if (list != null) {
      Iterator<StringBuilder> iterator = list.iterator();
      while (iterator.hasNext()) {
        StringBuilder string = iterator.next();
        writeS(string.toString());
      } 
    } 
  }
  
  public S_PacketBoxGame(StringBuilder title, ArrayList<StringBuilder> list) {
    this._byte = null;
    writeC(250);
    writeC(66);
    writeC(list.size() + 1);
    writeC(0);
    writeC(0);
    writeC(0);
    writeS(title.toString());
    if (list != null) {
      Iterator<StringBuilder> iterator = list.iterator();
      while (iterator.hasNext()) {
        StringBuilder c = iterator.next();
        writeS(c.toString());
      } 
    } 
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
